﻿using System;
using System.Globalization;
using System.Windows;
using System.Windows.Data;

namespace PLCWpfTest.Converters
{
    public class BooleanToVisibilityConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value == null)
            {
                throw new ArgumentNullException("Value can not be null");
            }
            Visibility visibility = (bool)value ? Visibility.Visible : Visibility.Collapsed;
            return visibility;
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value == null)
            {
                throw new ArgumentNullException("Value can not be null");
            }
            Visibility visibility = (Visibility)value;
            bool rs = visibility == Visibility.Visible;
            return rs;
        }
    }
}
